package org.xshop.web;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.xshop.model.THotSearch;
import org.xshop.service.ITHotSearchService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import top.ibase4j.core.base.AppBaseController;
import top.ibase4j.core.util.DataUtil;
import top.ibase4j.core.util.WebUtil;

/**
 * <p>
 * 商品热搜 前端控制器
 * </p>
 *
 * @author Liux
 * @since 2018-05-16
 */
@Controller
@RequestMapping("/app/search/")
@Api(tags = "HotSearch", value = "商品-热搜", description = "商品-热搜")
public class HotSearchController extends AppBaseController<THotSearch, ITHotSearchService> {
	@ApiOperation(value = "热门搜索", notes = "热门搜索", produces = MediaType.APPLICATION_JSON_VALUE, response = THotSearch.class)
	@RequestMapping(value = "getHot.api", method = { RequestMethod.GET, RequestMethod.POST })
	public Object getHot(HttpServletRequest request, String memberId) {
		Map<String, Object> param = WebUtil.getParameter(request);
		Long id = getCurrUser(request);
		if (DataUtil.isNotEmpty(id)) {
			param.put("memberId", id);
		}
		param.put("order", "desc");
		param.put("sort", "times_");
		return super.query(param);
	}

}
